//
//  HomePageListNavCell.m
//  ShowYork
//
//  Created by hxh on 2020/9/29.
//  Copyright © 2020 hxh. All rights reserved.
//

#import "HomePageListNavCell.h"

@interface HomePageListNavCell ()
@property (nonatomic,strong)UIImageView *bgImgView;
@property (nonatomic,strong)UILabel *targetDateLb;
@property (nonatomic,strong)UILabel *titleLb;
@property (nonatomic,strong)UILabel *resultDateLb;
@property (nonatomic,strong)UILabel *unitLb;
@property (nonatomic,strong)UIImageView *unitView;
@property (nonatomic,strong)CAGradientLayer *gradientLayer;
@property (nonatomic,strong)UIImageView *loadingImgView;
@property (nonatomic,strong)UILabel *loadingMainTitleLb;
@property (nonatomic,strong)UILabel *loadingSubTitle;
@end

@implementation HomePageListNavCell

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setUI];
    }
    return self;
}

- (void)setUI{
    self.bgImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"home_nav_tag"]];
    [self.contentView addSubview:self.bgImgView];
    [self.bgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(self.contentView);
    }];
    
    self.targetDateLb = [[UILabel alloc]init];
    self.targetDateLb.text = @"目标日：2021年6月7日";
    self.targetDateLb.textColor = [UIColor whiteColor];
    self.targetDateLb.font = font(12);
    [self.contentView addSubview:self.targetDateLb];
    
    [self.targetDateLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView).offset(-45);
        make.left.equalTo(self.contentView).offset(24);
    }];
    
    self.titleLb = [[UILabel alloc]init];
    self.titleLb.text = @"高考倒计时";
    self.titleLb.textColor = [UIColor whiteColor];
    self.titleLb.font = [UIFont boldSystemFontOfSize:24];
    [self.contentView addSubview:self.titleLb];
    
    [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.targetDateLb.mas_top).offset(-4);
        make.left.equalTo(self.targetDateLb);
    }];
    
    
    self.resultDateLb = [[UILabel alloc]init];
    self.resultDateLb.textColor = [UIColor whiteColor];
    self.resultDateLb.font = [UIFont boldSystemFontOfSize:48];
    [self.contentView addSubview:self.resultDateLb];
    
    [self.resultDateLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.targetDateLb);
        make.right.equalTo(self.contentView).offset(-48);
        make.height.mas_equalTo(67);
    }];
    
    self.unitView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"home_dateBackground_tag"]];
    self.unitView.layer.cornerRadius = 4;
    self.unitView.layer.masksToBounds = YES;
    [self.contentView addSubview:self.unitView];
    [self.unitView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-24);
        make.bottom.equalTo(self.resultDateLb).offset(-16);
    }];
    
    self.unitLb = [[UILabel alloc]init];
    self.unitLb.text = @"天";
    self.unitLb.textColor = [UIColor whiteColor];
    self.unitLb.font = font(12);
    [self.contentView addSubview:self.unitLb];
    
    [self.unitLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.unitView);
    }];
    
    self.loadingImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"home_loadingBackground_tag"]];
    [self.contentView addSubview:self.loadingImgView];
    
    self.loadingMainTitleLb = [[UILabel alloc]init];
    self.loadingMainTitleLb.text = @"预祝";
    self.loadingMainTitleLb.textColor = [UIColor whiteColor];
    self.loadingMainTitleLb.font = font(12);
    [self.contentView addSubview:self.loadingMainTitleLb];
    
    self.loadingSubTitle = [[UILabel alloc]init];
    self.loadingSubTitle.text = @"高考大捷！";
    self.loadingSubTitle.textColor = [UIColor whiteColor];
    self.loadingSubTitle.font = font(18);
    [self.contentView addSubview:self.loadingSubTitle];
    
    [self.loadingImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.titleLb);
        make.right.equalTo(self.contentView).offset(-84);
    }];
    [self.loadingMainTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.loadingImgView);
    }];
    [self.loadingSubTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.loadingImgView);
        make.top.equalTo(self.loadingImgView.mas_bottom).offset(4);
    }];
    
    self.loadingMainTitleLb.hidden = YES;
    self.loadingSubTitle.hidden = YES;
    self.loadingImgView.hidden = YES;
}

- (void)bindViewModel:(HomePageNavModel *)viewModel{
    self.targetDateLb.text = viewModel.targetDate;
    self.resultDateLb.text = viewModel.resultDate;
    self.unitLb.text = viewModel.isToday?@"时":@"天";
}

@end
